home *** CD-ROM | disk | FTP | other *** search
- Path: apm-b325-8.ucsd.edu!user
- From: bredelin@sdcc13.ucsd.edu (Benjamin Redelings)
- Newsgroups: comp.lang.c++
- Subject: Asynchronous I/O, Re: cin.get() function challenge
- Date: 31 Jan 1996 21:14:00 GMT
- Organization: University of California, San Diego
- Message-ID: <bredelin-3101961313580001@apm-b325-8.ucsd.edu>
- References: <4eavds$d0u@news.cencom.net> <ALUN.CHAMPION.96Jan29143951@g7240065.bridge.bst.bls.com>
- NNTP-Posting-Host: apm-b325-8.ucsd.edu
-
- I've been trying to find a read routine that doesn't block (i.e. wait to
- return) until a carriage return is entered. My program needs to
- continuously process data, stopping periodically to process any input that
- may have enterred the keyboard buffers since that last time it checked.
-
-
- A. On method would be the check the size of the keyboard buffer, called
- cin.get() only if a complete line is present. That would be optimal, and
- would not involve any blocking. However, whoever wrote iostream went to
- great lengths to make sure that checking the size of cin's buffer is
- really nasty. I think I would have to write my own io library just to
- check the size of the keyboard buffer!
-
- B. The other method would be to read all the input that is available, and
- process if necessary. However, if there is NO input, cin.get() WAITS for
- a carriage return, which means that the user must press return every time
- cin.get() is called to make the program keep processing. That is
- ridiculous.
-
- However, Alun Champion says
- >
- > It is the host environment which line buffers.
- > In the UNIX environment you can use ioctl() calls to change the
- > buffering characteristics of the terminal attached to cin, in other
- > environments there may or may not be a mechanism by which you can
- > inform the environment that line buffering is not to be performed.
- > This is very dependent on the host environment, try a programmers
- > newsgroup for the environment you are interested in.
- >
-
- Does anyone have more information? How does one go about this, and what
- might cin.get() be expected to return if it underflowed?
-
- Thanks,
- BenRI
-